package com.control.qct.businesssteward.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.control.qct.businesssteward.R;
import com.control.qct.businesssteward.model.GoodsModel;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.control.qct.businesssteward.utils.DecimalFormatUtils;
import com.control.qct.businesssteward.utils.GlideUtil;

import java.util.List;

/**
 * Created by Administrator on 2017/12/16 0016.
 */

public class GoodsAdapter extends BaseQuickAdapter<GoodsModel.DatasBean, BaseViewHolder> {
    public GoodsAdapter(@Nullable List<GoodsModel.DatasBean> data) {
        super(R.layout.rv_goods_detail_item, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, GoodsModel.DatasBean item) {
        GlideUtil.loadImage(mContext,item.getImageSmallUrl(), (ImageView) holder.getView(R.id.iv_goods_picture));
        holder.setText(R.id.tv_goods_name, item.getTitle() + "/" + item.getUnit()).setText(R.id.tv_goods_barcode,
                item.getBarcode()).setText(R.id.tv_goods_type, item.getCategoryTitle()).setText(R.id.tv_goods_status,
                item.getState().equals("已上架") ? "" : item.getState()).setText(R.id.tv_goods_price, "￥" +
                DecimalFormatUtils.DecimalFormatTwo(item.getSysPrice()));
    }
}
